package medium;

import java.util.ArrayList;
import java.util.List;

public class Lc784 {
    private class Solution {
        private List<String> ret = new ArrayList<>();

        private String[] split;
        public List<String> letterCasePermutation(String s) {
            split = s.split("");
            dfs("", 0);
            return ret;
        }

        void dfs(String s, int index) {
            if (index >= split.length) {
                ret.add(s);
                return;
            }
            if (!isDigit(split[index])) {
                dfs(s + split[index].toUpperCase(), index + 1);
                dfs(s + split[index].toLowerCase(), index + 1);
            }
            else {
                dfs(s + split[index], index + 1);
            }
        }

        private boolean isDigit(String s) {
            return s.compareTo("0") >= 0 && s.compareTo("9") <= 0;
        }
    }
}

